$(function () {
	//我知道了
	$(".timeOut .modal-container .ok-btn").click(function(){
	      $(".timeOut .modal-container").fadeOut(300);
	      location.href = "index";
	});
	
	//确认支付
	$(".order-bottom .pay-btn").click(function(){
		$(".mask .modal-container").fadeIn(300);
	});
	
	 //取消支付
	$(".mask .modal-container .cancel-btn").click(function(){
		$(".mask .modal-container").fadeOut(300);
	});
	
	//支付成功，查看订单
	$(".pay-ok .modal-container .ok-btn").click(function(){
		//获取uid
		var uid = $("#uid").val();
		location.href = "order.do?uid="+uid;
	});
  
	//返回首页
	$(".pay-ok .modal-container .back").click(function(){
		location.href = "index";
	});
	
	//确认支付
	  $(".mask .modal-container .ok-btn").click(function(){
		  //获取订单号
		  var orderNum = $("#orderNum").val();
		  $.ajax({
				url:"pay.do",
				type:"get",
				data:{
					"orderNum":orderNum
				},
				dataType:"json",
				success:function(data){
				}
			});
		  $(".mask .modal-container").hide();
		  $(".pay-ok .modal-container").fadeIn(300);
	  });
});
  /*
   时间倒计时
   TimeDown.js
   */
  function TimeDown(totalSeconds) {
    //取模（余数）
    var modulo = totalSeconds % (60 * 60 * 24);
    //小时数
    var hours = Math.floor(modulo / (60 * 60));
    modulo = modulo % (60 * 60);
    //分钟
    var minutes = Math.floor(modulo / 60);
    //秒
    var seconds = modulo % 60;
  
    //补零
    // hours = hours.toString().length == 1 ? '0' + hours : hours;
    // minutes = minutes.toString().length == 1 ? '0' + minutes : minutes;
    seconds = seconds.toString().length == 1 ? '0' + seconds : seconds;

    //输出到页面
    $(".status-box.unpaid .minute").html(minutes);
    $(".status-box.unpaid .second").html(seconds);

    //延迟一秒执行自己
    if(hours == "00" && minutes == "00" && parseInt(seconds)-1<0){
        $(".timeOut .modal-container").fadeIn(300);
        //获取订单号,删除订单
	  	var orderNum = $("#orderNum").val();
        $.ajax({
			url:"removeOrder.do",
			type:"get",
			data:{
				"orderNum":orderNum,
				"flag":1
			},
			dataType:"json",
			success:function(data){
			}
		})
    }else{
      setTimeout(function () {
        TimeDown(totalSeconds-1);
      }, 1000)
    }
}